avoid overhead of fcntl when setting close-on-exec
authorJoey Hess <joeyh@joeyh.name>
Thu, 4 Sep 2025 19:04:03 +0000 (15:04 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 4 Sep 2025 19:04:03 +0000 (15:04 -0400)
commit6ba848d2756cf7dd33c6bc5f5148d9ffca33340b
tree380ab6ac8e64891b61bff5910ddee6e9b62f8406
parente1dcf98b7850d50cfb5355fc8a510c319aaba3b2
avoid overhead of fcntl when setting close-on-exec

unix-2.8.0 adds cloexec to OpenFileFlags, rather than needing to call
setFdOption after opening.

This also might avoid a race, if another thread started a process at
just the wrong time, before the flag got set, it could inherit the FD.

Unfortunately, the arm64-ancient build needs support for older versions
of unix than that, so had to ifdef. That build is still needed to
support using git-annex in termux on phones like mine, I have confirmed
today.

Sponsored-by: Luke T. Shumaker
Git/LockFile.hs
Utility/LockFile/Posix.hs